<!DOCTYPE html>
<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
    <%@ include file="include.inc.jsp"  %>
<html>
<head>
    <title></title>
    <link href="lib/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" />
    <link href="lib/ligerUI/skins/Gray/css/all.css" rel="stylesheet" type="text/css" />
    
    <link href="bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
    
    <script src="lib/jquery/jquery-1.9.0.min.js" type="text/javascript"></script>
    <script src="lib/ligerUI/js/ligerui.all.js" type="text/javascript"></script>
    <!-- <script src="lib/ligerUI/js/core/base.js" type="text/javascript"></script> 
    <script src="lib/ligerUI/js/plugins/ligerGrid.js" type="text/javascript"></script>
    <script src="lib/ligerUI/js/plugins/ligerResizable.js" type="text/javascript"></script>
    <script src="lib/ligerUI/js/plugins/ligerCheckBox.js" type="text/javascript"></script>
    <script src="lib/ligerUI/js/plugins/ligerDrag.js" type="text/javascript"></script> 
    <script src="lib/ligerUI/js/plugins/ligerDialog.js" type="text/javascript"></script> -->
    <script type="text/javascript">
    
	    function deleteRow(){ 
	        //manager.deleteSelectedRow();
	        $.ligerDialog.warn('删除后不可恢复，暂时不能删除！');
	    }
	    
	    function edit(id){
	    	//alert(id);
	    	if(id!=null){
	    		var rowData=manager.getRow(id);
	    		var title='修改'+rowData.gName;
	    	}else{
	    		//var rowData={};
	    		$("#form input[id]").val('');
	    		var title='添加';
	    	}
	    	form.setData(rowData);
	    	$.ligerDialog.open({target: $("#target"),width:600,title:title});
	    }
	    
	    function save(){
	    	$.ajax({
	    		url:'${ctx}/bank/save',
	    		type:'POST',
	    		data:form.getData(),
	    		success:function(data){
	    			$('.l-dialog-close').trigger('click');
	    			$.ligerDialog.success(data.msg);
	    			if(data.success){
	    				manager.reload();
	    				$.ligerDialog.success('保存成功');
	    			}else{
	    				$.ligerDialog.warn('保存出现异常');
	    			}
	    		},
	    		error:function(data){
	    			$.ligerDialog.error('服务器出现异常');
	    		}
	    	});
	    }
	    
	    var manager=null;
	    var form=null;
        $(function () {
        	//生成表格
            manager=$("#maingrid").ligerGrid({
                columns: [
                { display: '开户名', name: 'bName', align: 'left', width: 100, minWidth: 60 },
                { display: '银行卡号', name: 'bNumber', minWidth: 120 },
                { display: '金额', name: 'bMoney', minWidth: 140 },
                { display: '操作', name:'bId',isSort: false, width: 120, render: function (rowdata, rowindex, value){
                		//console.log(rowdata);console.log(rowindex);console.log(value);
                        return "<a href='javascript:void(0)' onclick='edit(\""+ rowindex + "\")'>修改</a> ";;
                    }
                 }
                ], 
                sortName: 'CustomerID',
                checkbox:true,
                usePager:false,
                url:'${ctx}/bank/getAll'
            });
            $("#pageloading").hide();
            
          //创建表单结构 
            form=$("#form").ligerForm({
                //inputWidth: 170, labelWidth: 90, space: 40,
                height:28,
                fields: [
                { name: "bId", type: "hidden" },
                { display: "开户名", name: "bName", newline: false, type: "text"/* , groupicon: groupicon */},
                { display: "银行卡号", name: "bNumber", newline: false, type: "number"},
                { display: "金额 ", name: "bMoney", newline: false, type: "text"  },
                /* { display: "零售价", name: "gSaleprice", newline: false, type: "number" },
                { display: "备注", name: "gMemo", newline: false, type: "text"} */
                ]
            });
        });
    </script>
</head>
<body style="overflow-x:hidden">
<div class="l-loading" style="display:block" id="pageloading"></div>
<div class="container">
	<h5>
		<button onclick="edit()" type="button" class="btn btn-primary">添加</button>
		<button onclick="deleteRow()" type="button" class="btn btn-primary">删除</button>
	</h5>	
	<div id="maingrid"></div>
</div>
<div style="display:none" id="target">
<div id="form"></div>
<div class="highlight">
<button onclick="$('.l-dialog-close').trigger('click')" style="float:right;margin-right:15px" type="button" class="btn btn-default">取消</button>
<button onclick='save()' style="float:right;margin-right:15px" type="button" class="btn btn-primary">保存</button>
</div>
	
</div>
</body>
</html>
